package com.kfm.hotel.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.yulichang.extension.mapping.config.DeepConfig;
import com.kfm.hotel.domain.Room;
import com.kfm.hotel.domain.SysUser;
import com.kfm.hotel.service.RoomService;
import com.kfm.hotel.mapper.RoomMapper;
import org.springframework.stereotype.Service;
import java.util.List;

/**
* @author Lenovo
* @description 针对表【room】的数据库操作Service实现
* @createDate 2023-06-16 21:24:06
*/
@Service
public class RoomServiceImpl extends ServiceImpl<RoomMapper,Room>
    implements RoomService{


    @Override
    public PageInfo<Room> list(Room room, Integer page, Integer limit) {
        //查询条件
        QueryWrapper<Room> wrapper = new QueryWrapper<>();
        wrapper.eq("state",1);
        wrapper.eq("is_del",0);
        //分页封装成pageinfo对象
        // 查询并封装成 PageInfo 对象
        // 分页
        PageHelper.startPage(page, limit);
       // List<Room> rooms = getBaseMapper().selectList(wrapper);
        //conf -> conf.loop(true):循环查询
        List<Room> rooms = listDeep(wrapper, conf -> conf.loop(true));
        PageInfo<Room> pageInfo = new PageInfo<>(rooms);
        return pageInfo;
    }

    @Override
    public boolean updateState(Integer id, Integer state) {
        UpdateWrapper<Room> wrapper=new UpdateWrapper<>();
        wrapper.eq("room_state",state);
        wrapper.eq("id",id);
        return update(wrapper);
    }

//    @Override
//    public List<RoomType> getRoomTypes() {
//        QueryWrapper<RoomType> wrapper = new QueryWrapper<>();
//        wrapper.eq("state",1);
//        wrapper.eq("is_del",0);
//        return list(wrapper);
//    }
}




